/**  
 
* @author xuzhixiang 

* @date 2018年10月7日  

*/  
package com.moxi.study.hadoop.mapReduce;

import java.io.IOException;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

/**
 * Mapper测试
 * 需要继承Mapper
 * LongWritable： 行的偏移量
 * 其中 Text表示输入的k-v 和输出的 k-v
 * @author xuzhixiang
 * @date 2018年10月7日下午6:56:05  
 */
public class TestMapper extends Mapper<LongWritable, Text, Text, IntWritable>{

	@Override
	protected void map(LongWritable key, Text value, Mapper<LongWritable, Text, Text,
			IntWritable>.Context context) throws IOException, InterruptedException {
		Text keyOut = new Text();
		IntWritable valueOut = new IntWritable();
		String [] arr = value.toString().split(" ");
		for (String s : arr) {
			keyOut.set(s);
			valueOut.set(1); //每个单词后面加个1
			context.write(keyOut, valueOut);			
		}
	}
	
	
}
